package cn.hchaojie.javase.day01;

import org.junit.Test;

/**
 * junit单元测试类，
 * 
 * @author hchaojie
 *
 */
public class DemoFlow {
	
	@Test		// 注解，Annotation
	public void testIf() {
		System.out.println(absolute(-5));
		System.out.println(absolute(3));
		System.out.println(absolute(0));
		
		
		System.out.println(max(5, 3));
		System.out.println(max(3, 100));
		System.out.println(max(3, -100));
	}
	
	/**
	 * 返回给定值的绝对值
	 * @param x
	 */
	public static int absolute(int x) {
		if (x < 0) {
			x = -x;
		}
		
		return x;
	}
	
	/**
	 * 返回最大值
	 * @param x
	 * @param y
	 * @return
	 */
	public static int max(int x, int y) {
		if (x > y) {
			return x;
		} else {
			return y;
		}
	}
	
	public static void printScore(int score) {
//		if (score >= 90) {
//			System.out.println("优秀！");
//		} else if (score >= 60) {
//			System.out.println("及格！");
//		} else {
//			System.out.println("重修！");
//		}
		
		if (score < 60) {
			System.out.println("重修！");
		} else if (score < 90) {
			System.out.println("及格！");
		} else {
			System.out.println("优秀！");
		}
	}
	
	@Test
	public void testScore() {
		printScore(99);
		printScore(80);
		printScore(54);
		printScore(0);
	}
	
	@Test
	public void testSwitch() {
//		printWeekDay(1);
		printWeekDay(2);
//		printWeekDay(3);
//		printWeekDay(8);
//		printWeekDay(9);
		
		System.out.println(isWorkDay(1));
		System.out.println(isWorkDay(7));
	}
	
	public static void printWeekDay(int i) {
//		if (i == 1) {
//			System.out.println("星期一");
//		} else if (i == 2) {
//			System.out.println("星期二");
//		}
		
		switch (i) {
		case 1:
			System.out.println("星期一");
			break;

		case 2:
			System.out.println("星期二");
			break;

		case 3:
			System.out.println("星期三");
			break;

		default:
			System.out.println("错误的星期天数！");
			break;
		}
	}
	
	public static boolean isWorkDay(int i) {
		boolean flag = false;
		switch (i) {
		case 1:
		case 2:
		case 3:
		case 4:
		case 5:
			flag = true;
			break;

		case 6:
		case 7:
			flag = false;
			break;

		default:
			System.out.println("输入错误！");
			break;
		}
		
		return flag;
	}
}
